import tornado.web
import tornado.ioloop
from . import utils
import json
'''
#
#6.4 清空目标库中所有图片
同步
    http://ip:port/face/clearDbFaces
    {
        "dbName":"",
        "id":"1"
    }

'''
class FaceclearDbFaces(tornado.web.RequestHandler):

    def post(self, *args, **kwargs):
        resp = None
        try:
            data=json.loads(self.request.body)
            print(data)
            paramerror = utils.checkParam(data,{
                "dbName":"",
                "id":"1"
            })
            if paramerror == '': #ok
                resp = {
                    "state":{
                        "ok":1,
                        "failed": ""
                    },
                    "result":"success",
                    "id":data['id']
                }
            else: #failed
                resp = {
                    "state":{
                        "ok":0,
                        "failed": paramerror
                    },
                    "result":""
                }

        except BaseException as e:
            resp = {
                "state":{
                    "ok":0,
                    "failed": str(e)
                },
                "result":""
            }

        self.write(resp)
